﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace DynamicAgent
{
    public interface IAopInterceptor
    {
        /// <summary>
        /// 执行目标方法前
        /// </summary>
        /// <param name="abstraceMethod"></param>
        /// <param name="implementMethod"></param>
        void Before(MethodInfo abstraceMethod, MethodInfo implementMethod);

        /// <summary>
        /// 执行目标方法后
        /// </summary>
        /// <param name="abstraceMethod"></param>
        /// <param name="implementMethod"></param>
        /// <param name="ex"></param>
        void After(MethodInfo abstraceMethod, MethodInfo implementMethod, Exception? ex);

        /// <summary>
        /// 执行目标方法前
        /// </summary>
        /// <param name="abstraceMethod"></param>
        /// <param name="implementMethod"></param>
        /// <returns></returns>
        ValueTask BeforeAsync(MethodInfo abstraceMethod, MethodInfo implementMethod);

        /// <summary>
        /// 执行目标方法后
        /// </summary>
        /// <param name="abstraceMethod"></param>
        /// <param name="implementMethod"></param>
        /// <param name="ex">若目标方法执行出错则ex会有异常信息</param>
        /// <returns></returns>
        ValueTask AfterAsync(MethodInfo abstraceMethod, MethodInfo implementMethod, Exception? ex);
    }
}
